﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace day3_case2
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //int[] a = new int[3];
            //a[0] = 8;
            //a[1] = 10;
            //a[2] = 20;
            //for(int i=0; i<a.Length; i++)
            //{
            //    Console.WriteLine(a[i]);
            //}
            //foreach (int i in a)
            //{
            //    Console.WriteLine(i);
            //}

            //string[] b = new string[4] { "春天","夏天","秋天","冬天"};
            //Console.WriteLine("中文的一年四季：");
            //for (int i=0; i<b.Length; i++)
            //{
            //    Console.WriteLine(b[i]);
            //}
            //b[0] = "spring";
            //b[1] = "summer";
            //b[2] = "autumn";
            //b[3] = "winter";
            //foreach (string i in b)
            //{
            //    Console.WriteLine(i);
            //}


            //int[] c = new int[3] { 10,20,30};
            //c[1] = c[1] + 1;
            //for (int i = 0; i < c.Length; i++)
            //{
            //    Console.WriteLine(c[i]);
            //}
            //foreach (int x in c)
            //{
            //    Console.WriteLine(x);
            //}
            //Console.WriteLine(new string('*', 50));

            //Console.Read();


            //while i > 0:  # 外层循环控制的无序数的数目
            //j = 0
            //flag = 1
            //while j < i:
            //    if arr[j] > arr[j + 1]:
            //        arr[j], arr[j + 1] = arr[j + 1], arr[j]
            //        flag = 0
            //    j += 1
            //if flag:  # 如果某一趟没有交换过，就代表已经有序
            //    break
            //i -= 1

            int[] c = new int[3] { 10, 20, 30 };
            int i = c.Length;
            while (i>0)
            {
                int j = 0;
                int flag = 1;
                while (j<i) {
                if (c[j] >= c[j+1]) {
                        int temp=0;
                        temp = c[j + 1];
                        c[j + 1] = c[j];
                        c[j] = temp;
                        flag = 0;

                    }
                if(flag == 0) {
                        break;

                    }
                    i -= 1;
                }
            }
            foreach (int i in c)
            {
                Console.WriteLine(i);
            }

        }
    }
}
